<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
	<div class="col-sm-12 select-info">
		<form id="menu-form">
			<div class="select-list">
				<ul>
					<li class="select-time">
						<label>充值时间： </label>
						<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
						<span>-</span>
						<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
					</li>
					<li>
						<label>类型：<label>
						<select name="billType" th:with="type=${@dict.getType('bill_type')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:hidden="${dict.dictValue == '3'}"></option>
						</select>
					</li>
					<li style="display: flex;align-items: center;width: 180px;">
						<label style="min-width: 40px;margin-bottom: 0px;">用户：</label>
						<select name="userId" class="form-control" style="width: 100px">
							<option value="">请选择用户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
							<option th:each="user:${users}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}"></option>
						</select>
					</li>
					<li>
						<label>部门：</label>
						<input type="text" name="deptName" placeholder="请输入部门名称"/>
					</li>
					<li>
						<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
						<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						<!--<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel('menu-form')" shiro:hasPermission="system:post:export"><i class="fa fa-download"></i>&nbsp;导出</a>-->
					</li>
				</ul>
			</div>
		</form>
	</div>
	<div class="btn-group hidden-xs" id="toolbar" role="group">
		<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="finance:bill:add">
			<i class="fa fa-plus"></i> 单笔充值
		</a>
		<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.batchadd()" shiro:hasPermission="finance:bill:batchadd">
			<i class="fa fa-plus"></i> 批量充值
		</a>
	</div>

	<div class="col-sm-12 select-table table-striped">
		<table id="bootstrap-table" data-mobile-responsive="true"></table>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('finance:bill:edit')}]];
    var prefix = ctx + "finance/bill"

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            batchCreateUrl: prefix + "/batchadd",
            updateUrl: prefix + "/edit/{id}",
            modalName: "充值",
            search: false,
            columns: [{
                field : 'billType',
                title : '类型',
                align: 'center',
                formatter: function(value) {
                    return $.table.billTypeLabel(value);
                }
            },{
                field : 'serialNo',
                title : '流水号'
            },
                {
                    field : 'userId',
                    title : '人员编号'
                },
                {
                    field : 'userName',
                    title : '姓名'
                },
                {
                    field : 'deptName',
                    title : '部门'
                },
                {
                    field : 'price',
                    title : '充值金额',
                    formatter: function(value, row) {
                        var type = row.billType;
                        return $.table.billMoneyLabel(value, type);
                    }
                },
                {
                    field : 'money',
                    title : '余额'
                },
                {
                    field : 'operator',
                    title : '操作人'
                },
                {
                    field : 'createTime',
                    title : '操作时间'
                },
                {
                    field : 'describes',
                    title : '相关流水'
                },
                {
                    field : 'remark',
                    title : '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row) {
                        if(row.billType != 2 && !row.describes) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.billId + '\')"><i class="fa fa-edit"></i>冲账</a> ');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>